home *** CD-ROM | disk | FTP | other *** search
-
-
- SUPER-SIMPLE FILE SEARCHING !!
-
-
- This program was designed to be smaller than the incredibly large file-finders
- currently available in the Shareware market. Although it does not scan inside
- compressed files, it does search within hidden directories, and successfully
- locates hidden, system, and read-only files.
-
- This was written on May 26, 1991 with Turbo C++ Professional package.
-
- It is freeware. You are free to distribute the code as you like, or use
- it as a SHELL for a more complicated, exhaustive searching utility. My
- purpose for releasing the code is to give beginning programmers a guide for
- ENTIRE-DISK functioning.
-
- (Compiled with: TCC -ms lookin whooper.asm)
-
-
- Add-on "C" coding could provide:
-
- 1) Searching tools that cover all disk drives available, and look inside
- compressed files.
-
- 2) Global file execution.
-
- 3) Disk-wide text searching.
-
- 4) Directory Listing.
-
- 5) Quick-directory changers.
-
- 6) File-spec searches.
-
- and many MORE, limited only to programming imagination (and God knows that's unlimited!!).
-
-
- If you make improvements on this code, please let me know !! I love to learn
- new utilities, and always learn A LOT from seeing healthy "C" coding ...
-
-
- DAVE SMITH
-
- Compuserve 71441,2723
-
-
-
-
-
- ===================================================================================
-
- #include <dos.h>
- #include <string.h> /* SET-UP FOR PROGRAM */
- #include <stdio.h>
- #include <dir.h>
-
- void lookinpath(void); /* FUNCTION CALLED RECURSIVELY UNTIL ALL PATHS ARE FOUND */
-
- extern Whooper(void); /* EXTERNAL ASSEMBLY PROGRAM FOR WHOOPING SOUND */
-
- char file[20]; /* Holds part-name or full filename for search */
- char curdir[15]; /* Current directory while searching */
-
- int a=0; /* Counts # of files found. Mainly used to determine */
- /* whether or not a file-match was located */
-
- void main(int argc, char *argv[])
- {
-
- char camefrom[30]; /* Original starting directory */
-
- if(argc < 2){ printf("\nUsage: LOOKIN [filename/partname]\n"); exit(0); }
-
-
- /* FILENAME IS COPIED INTO "file" THEN UPPER-CASED */
-
- strcpy(file,argv[1]);
- strupr(file);
-
-
- /* GET DIRECTORY WE ARE IN, CHANGE INTO ROOT, THEN CALL DIRECTORY-SEARCH FUNCTION */
-
- getcurdir(0,camefrom);
-
- chdir("\\");
- lookinpath();
-
-
- /* CHANGE BACK TO WHERE WE STARTED AND SHOW RESULTS */
-
- chdir(camefrom);
-
- if(a==0) printf("\nNo match found──",file);
- printf("\n");
-
- Whooper();
- exit(0);
-
- }
-
- void lookinpath(void)
- {
-
- int found;
- struct ffblk dave;
-
- /** FIND ALL FILES IN DIRECTORY, THEN FIND FIRST OCCURANCE OF THE STRING
- **
- ** SPECIFIED ON COMMAND LINE.
- **/
-
- found=findfirst("*.*",&dave,47);
- while(!found)
- {
-
- if(strstr(dave.ff_name,file))
- {
- strcat(dave.ff_name,"$"); /* Setup for DOS function call */
- strcat(curdir,"$");
-
- r.h.ah=0x09; /* I utilize the function call for the */
- r.x.dx=FP_OFF("Found-$"); /* simple fact that Printf() is slow, bulky */
- s.ds=FP_SEG("Found-$"); /* and looks "draggy" in faster coding */
- intdosx(&r,&r,&s); /* */
- /* I use the printf() call below, because */
- r.x.dx=FP_OFF(dave.ff_name); /* my main information is printed and */
- s.ds=FP_SEG(dave.ff_name); /* I can relax my output by that time */
- intdosx(&r,&r,&s); /* */
- /* Beginners might want to use: */
- r.x.dx=FP_OFF(" ═══$"); /* Printf("Found-%s═══%s",dave.ff_name,curdir)*/
- s.ds=FP_SEG(" ═══$");
- intdosx(&r,&r,&s);
-
- r.x.dx=FP_OFF(curdir);
- s.ds=FP_SEG(curdir);
- intdosx(&r,&r,&s);
-
- printf("\n"); /* Throw a line-feed in */
- a++;
- }
-
- found=findnext(&dave);
- }
-
-
- /* ONCE ALL FILES ARE SEARCHED, LOOK INTO ALL DIRECTORIES */
-
- found=findfirst("*.*",&dave,FA_DIREC+FA_SYSTEM+FA_HIDDEN);
- while(!found)
- {
-
- if(((dave.ff_attrib & FA_DIREC)==FA_DIREC)&&(dave.ff_name[0] !='.'))
- {
-
- strcpy(curdir,dave.ff_name);
-
- chdir(dave.ff_name); /* Change into newly found directory */
-
- lookinpath(); /* <------Function called recursively */
-
- chdir(".."); /* Once all possible directories here have been */
- /* exhausted, go up one and continue with other */
- /* recursive calls. */
-
- }
- found=findnext(&dave);
- }
-
- }
-
-